﻿using UnityEngine;
using UnityEngine.UI;

namespace com.tdb.foundation
{
    [RequireComponent(typeof(Text))]
    public class LocalizationText : MonoBehaviour
    {
        private Text _text;

        private string _key;
        void Start()
        {
            _text = GetComponent<Text>();
            _key = _text.text;
            _text.text = Singleton<LocalizationManager>.Instance.Get(_key);
        }

        public void Reset(string key, params string[] contents)
        {
            _key = key;
            ReFormat(contents);
        }

        public void ReFormat(params string[] contents)
        {
            _text.text = Singleton<LocalizationManager>.Instance.Get(_key, contents);
        }
    }

}

